char s[64][32],
n[30][15]=
{ "9", "7", "21", "63", "89", "67", "801", "6403", "59209", "77627", "32881", "98643", "095929", "03287787", "09863361", "9590083", "88770249", "66310747", "3298932241", "96796723", "59690390169", "79071170507", "37213511621", "11640534563", "34921603689", "4504764811067", "14294433201", "10542883299603", "31628649898809", "94885949696427" }; 
a[30]= { 1, 1, 2, 2, 2, 2, 3, 4, 5, 5, 5, 5, 6, 8, 8, 7, 8, 8, 10, 8, 11, 11, 11, 11, 11, 13, 11, 14, 14, 14 };
main(i,w)
{
	for(i=0;i<64;i++)
	{
		sprintf(s[i],"%.lf",pow(3,i));
		if(i>33)strcpy(s[i]+strlen(s[i])-a[i-34],n[i-34]);
	}

	unsigned long long n;
	for(;~scanf("%llu",&n)&&n;puts(" }"))
	{
		printf("{");
		if(n==1)
			continue;

		for(w=0,i=1,--n;n;i++)
			if(pow(2,i)-1>=n)
			{
				n-=pow(2,i-1);
				a[w++]=i-1;
				i=0;
			}
		
		for(;w--;w?printf(","):w)
		{
			printf(" %s",s[a[w]]);
		}
	}
}
